package org.repo.ant.util;

import org.apache.tools.ant.BuildException;

public class ValidationUtil {

	public static class RepoJavac {

		public static void validateParams(String repo, String repoBase, String repoDirectory, String repoIncludesFile, String repoExcludesFile) throws BuildException {
			validateRepo(repo, repoDirectory);
			validateIncludes(repoIncludesFile, repoExcludesFile);
		}

	}

	public static class RepoJar {

		public static void validateParams(String repo, String repoBase, String repoDirectory) throws BuildException {
			validateRepo(repo, repoDirectory);
		}

	}


	public static void validateRepo(String repo, String repoDirectory) throws BuildException {
		if (repo == null && repoDirectory == null) {
			throw new BuildException("You need to specify either the 'repo' or 'repoDirectory' property.");
		}
		if (repo != null && repoDirectory != null) {
			throw new BuildException("You can only use one of the 'repo' or 'repoDirectory' properties.");
		}
	}

	public static void validateIncludes(String repoIncludesFile, String repoExcludesFile) throws BuildException {
		if (repoIncludesFile != null && repoExcludesFile != null) {
			throw new BuildException("You can only use one of the 'repoIncludesFile' or 'repoExcludesFile' properties.");
		}
	}
	
}
